home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / SKIP.ASM < prev    next >
Assembly Source File  |  1989-11-11  |  3KB  |  143 lines

  1. ;skip.asm - low level stuff to help compress pictures into FLI's.
  2. ;:ts=10
  3.  
  4.     TITLE   skip
  5. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  6. _TEXT    ENDS
  7. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  8. _DATA    ENDS
  9. CONST    SEGMENT  WORD PUBLIC 'CONST'
  10. CONST    ENDS
  11. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  12. _BSS    ENDS
  13. DGROUP    GROUP    CONST,    _BSS,    _DATA
  14.     ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  15. _TEXT      SEGMENT
  16.  
  17.     PUBLIC _fii_tnskip
  18. ;fii_tnskip(s1,s2,bcount,mustmatch)
  19. s1    equ    [bp+4+2]
  20. s1s    equ    [bp+6+2]
  21. s2    equ    [bp+8+2]
  22. s2s    equ    [bp+10+2]
  23. bcount    equ    [bp+12+2]
  24. mmatch    equ    [bp+14+2]
  25. _fii_tnskip    proc far
  26. difcount    equ    [bp-2]
  27.     push bp
  28.     mov bp,sp
  29.     sub sp,4    ;space for locals
  30.     push bx
  31.     push si
  32.     push di
  33.     push ds
  34.  
  35.     mov word ptr difcount,0    ;zero out return value
  36.     lds si,s1
  37.     les di,s2
  38.     mov bx,bcount
  39.     mov dx,mmatch
  40.  
  41. tnsloop:
  42.     ;calculate number of pixels different in s1 and s2 into ax
  43.     mov cx,bx
  44.     inc cx
  45.     repne cmpsb
  46.     mov ax,bx
  47.     sub ax,cx
  48.     dec si    ;move source pointers just past this different run
  49.     dec di
  50.     sub bx,ax
  51.     add difcount,ax    ;and different count to return value
  52.  
  53.     cmp bx,dx        ;see if near the end...
  54.     js endcheck
  55.  
  56.     ;see if enough in a row match to break out of this
  57.     mov cx,dx
  58.     repe cmpsb
  59.     jz zfii_tnskip    ;if all of them match between s1 and s2 go home
  60.     inc cx
  61.     mov ax,dx        ;calc ones that do match into ax
  62.     sub ax,cx
  63.     add difcount,ax    ;add it to difcount return value
  64.     sub bx,ax        ;sub it from pixels left to examine
  65.     dec si        ;update s1,s2 pointers
  66.     dec di
  67.     jmp tnsloop
  68. endcheck:
  69.     ;check last couple of pixels
  70.     mov cx,bx
  71.     inc cx
  72.     repe cmpsb
  73.     jcxz zfii_tnskip    ;if all of them match between s1 and s2 go home
  74.     add difcount,bx    ;otherwise assume no skip this time around
  75.  
  76. zfii_tnskip:
  77.     mov ax,difcount
  78.     pop ds
  79.     pop di
  80.     pop si
  81.     pop bx
  82.     mov sp,bp
  83.     pop bp
  84.     ret
  85. _fii_tnskip    endp
  86.  
  87.  
  88.     PUBLIC    _fii_tnsame
  89. ;fii_tnsame(s2x,wcount,mustmatch)
  90. s2x    equ [bp+4+2]
  91. wcount    equ word ptr[bp+8+2]
  92. mumatch    equ [bp+10+2]
  93. _fii_tnsame    PROC far
  94.     push bp
  95.     mov bp,sp
  96.     push ds
  97.     push si
  98.     push di
  99.     push bx
  100.  
  101.                 
  102.     les    di,s2x        ;get starting address in es:di
  103.     mov    dx,wcount        ;dx is 'dif_count' return value
  104.     mov    bx,dx        ;bx is # of pixels left
  105.     mov    si,0        ;si is # of pixels examined
  106. alp:
  107.                 ;break out of loop if less than 4 pixels
  108.                 ;left to examine
  109.     cmp    bx,mumatch
  110.     js    zalp
  111.  
  112.     ;same_count = i86_bsame(s2x,wcount)
  113.     mov cx,bx
  114.     mov al,es:[di]
  115.     rep scasb
  116.     inc cx
  117.     sub di,2
  118.     mov ax,bx
  119.     sub ax,cx
  120.  
  121.     cmp ax,mumatch            ;if mustmatch or more
  122.     jns gotsame        ;go truncate dif_count
  123.     add    si,ax
  124.     add    di,ax
  125.     sub    bx,ax
  126.     jmp    alp
  127. gotsame:
  128.     mov    dx,si        
  129. zalp:
  130.     mov ax,dx        ;return dif_count
  131.     pop bx
  132.     pop di
  133.     pop si
  134.     pop ds
  135.     pop bp
  136.     ret
  137.  
  138. _fii_tnsame    ENDP
  139.  
  140.  
  141. _TEXT    ENDS
  142. END
  143.